<?xml version="1.0" encoding="UTF-8"?>
<ui:composition xmlns="http://www.w3.org/1999/xhtml"
	xmlns:ui="http://java.sun.com/jsf/facelets"
	xmlns:f="http://java.sun.com/jsf/core"
	xmlns:h="http://java.sun.com/jsf/html"
	template="/resources/layout/templateInterno.xhtml"
	xmlns:a4j="http://richfaces.org/a4j"
	xmlns:t="http://myfaces.apache.org/tomahawk"
    xmlns:rich="http://richfaces.org/rich">
    
    
	<ui:define name="body">
		<div class="form">
		<h:form id="formCadastroIgreja">
		<h:panelGroup id="pgMensagens">
			  <div align="center">
					<h:messages  errorClass="form-msg-error" infoClass="form-msg-success" />
			</div>
		</h:panelGroup>
		<div  class="field-clear"></div>
		  <t:fieldset id="idfsDadosPessoais"  legend="Dados">
		  
		  		<div class="grid-1-12">
					<h:outputLabel id="lbCodigo" class="form-lbl"  value="Código:"/>
					<h:inputText  id="inptCodigo" disabled="true" styleClass="form-txt" value="#{igrejaCadastroBean.igreja.coSeqIgreja}" />
				</div> 
				<div class="grid-5-12">
					<h:outputLabel  id="lbNome" class="form-lbl"  value="Nome:"/>
					<h:inputText maxlength="100"  id="inptNome" styleClass="form-txt" required="true" requiredMessage="Favor informar o Nome." value="#{igrejaCadastroBean.igreja.nome}" />
				</div>
				<div class="grid-3-12">
					<h:outputLabel  id="lbCnpj" class="form-lbl"  value="CNPJ"/>
					<h:inputText  id="inptCnpj" styleClass="form-txt" value="#{igrejaCadastroBean.igreja.cnpj}" >
						 <rich:jQuery selector="#inptCnpj" query="mask('99.999.999/9999-99')" timing="onload"/>
					</h:inputText>					
				</div>
				 <div class="field-clear"></div>
				 <div class="grid-2-12">
					<h:outputLabel  id="lbCep" class="form-lbl"  value="CEP:"/>
					<h:inputText  id="inptCep" styleClass="form-txt" value="#{igrejaCadastroBean.igreja.cep}" >
						 <rich:jQuery selector="#inptCep" query="mask('999.999.999-99')" timing="onload"/> 
					</h:inputText>					
				</div>
				 <div class="grid-4-12">
					<h:outputLabel  id="lbLogradouro" class="form-lbl"  value="Logradouro:"/>
					<h:inputText maxlength="100"  id="inptLogradouro" required="true" requiredMessage="Favor informar o Logradouro."  styleClass="form-txt" value="#{igrejaCadastroBean.igreja.logradouro}" />
				</div>
				<div class="grid-2-12">
					<h:outputLabel  id="lbNumero" class="form-lbl"  value="Número:"/>
					<h:inputText style="width: 50px" id="inptNumero" required="true" maxlength="6" requiredMessage="Favor informar o Número." styleClass="form-txt" value="#{igrejaCadastroBean.igreja.numero}" >
						 <rich:jQuery selector="#inptNumero" query="numeric()" timing="onload"/>
					</h:inputText>
				</div>
				 <div class="field-clear"></div>	
				<div class="grid-4-12">
					<h:outputLabel  id="lbBairro" class="form-lbl"  value="Bairro:"/>
					<h:inputText  id="inptBairro" maxlength="100" required="true" requiredMessage="Favor informar a Bairro." styleClass="form-txt" value="#{igrejaCadastroBean.igreja.bairro}" />
				</div>
				<div class="grid-4-12">
					<h:outputLabel  id="lbCidade" maxlength="100" class="form-lbl"  value="Cidade:"/>
					<h:inputText  id="inptCidade" required="true" requiredMessage="Favor informar a Cidade." styleClass="form-txt" value="#{igrejaCadastroBean.igreja.cidade}" />
				</div>	
					
				<div class="grid-2-12" style="width: 60px">
					<h:outputLabel  id="lbUf" class="form-lbl"  value="UF:"/>
					<h:selectOneMenu required="true" style="width: 100px" requiredMessage="Favor informar a UF." id="cbUf" styleClass="form-txt" value="#{igrejaCadastroBean.igreja.uf}">
				 		<f:selectItem itemLabel="Selecione ..." itemValue=""/>
				 		<f:selectItems value="#{igrejaCadastroBean.listaUfs}" />
			 		</h:selectOneMenu>
				</div>
				<div class="field-clear"></div>
				<div class="grid-2-12">
					<h:outputLabel  id="lbDataInauguracao" class="form-lbl"  value="Data Inauguração:"/>
					<rich:calendar  required="true" requiredMessage="Favor informar a Data Inauguração."  id="clDtInicial" firstWeekDay="0" minDaysInFirstWeek="2"
							value="#{igrejaCadastroBean.igreja.dtInauguracao}" 
							datePattern="dd/MM/yyyy" 
							inputSize="10" 
							inputClass="maskDate"
							enableManualInput="true" 
							disabled="false">
					</rich:calendar>
					<rich:jQuery id="mskDateCasamento" selector=".maskDate" timing="onload" query="mask('99/99/9999',{placeholder:' '})" />									
				</div>
				<div class="grid-3-12">
					<h:outputLabel  id="lbSituacao" class="form-lbl"  value="Situação:"/>
					<h:selectOneMenu  required="true" requiredMessage="Favor informar a Situação" id="cbSituacao" styleClass="form-txt" value="#{igrejaCadastroBean.igreja.situacao}">
				 		<f:selectItem itemLabel="Selecione ..." itemValue=""/>
				 		<f:selectItem itemLabel="IGREJA" itemValue="I"/>
				 		<f:selectItem itemLabel="CONGREGAÇÃO" itemValue="C"/>
			 		</h:selectOneMenu>
				</div>
				<div class="grid-2-12">
					<h:outputLabel  id="lbTipoIgreja" class="form-lbl"  value="Tipo Igreja:"/>
					<h:selectOneRadio id="cbTipoIgreja" required="true" requiredMessage="Favor informar o Tipo da Igreja." value="#{igrejaCadastroBean.igreja.tipoIgreja}">
						  <f:selectItem itemLabel="Sede" itemValue="S" />
						  <f:selectItem itemLabel="Filial" itemValue="F" />
					<a4j:support  event="onchange" ></a4j:support>  
					</h:selectOneRadio>	
				</div>
				 <div class="field-clear"></div>
				<div class="grid-2-12">
					<h:outputLabel  id="lbTelefone" class="form-lbl"  value="Telefone:"/>
					<h:inputText  id="inptTelefone" styleClass="form-txt" value="#{igrejaCadastroBean.igreja.telefone}" >
						 <rich:jQuery selector="#inptTelefone" query="mask('(99) 9999-9999')" timing="onload"/> 
					</h:inputText>					
				</div>
				<div class="grid-2-12">
					<h:outputLabel  id="lbTelefone2" class="form-lbl"  value="Telefone 2:"/>
					<h:inputText  id="inptTelefone2" styleClass="form-txt" value="#{igrejaCadastroBean.igreja.segundoTelefone}" >
						<rich:jQuery selector="#inptTelefone2" query="mask('(99) 9999-9999')" timing="onload"/>
					 </h:inputText>
					 					
				</div>
				<div class="grid-2-12">
					<h:outputLabel  id="lbCelular" class="form-lbl"  value="Celular:"/>
					<h:inputText  id="inptCelular" styleClass="form-txt" value="#{igrejaCadastroBean.igreja.celular}" >
						<rich:jQuery selector="#inptCelular" query="mask('(99) 9999-9999')" timing="onload"/>
					</h:inputText>					
				</div>
				<div class="grid-5-12">
					<h:outputLabel  id="lbEmail" class="form-lbl"  value="E-mail:"/>
					<h:inputText  id="inptEmail" styleClass="form-txt" value="#{igrejaCadastroBean.igreja.email}" />					
				</div>
		 </t:fieldset>
		 <div  class="field-clear"> </div>
			 <div style="margin-left: 300px" class="grid-3-12">
					<a4j:commandButton style="width:100px" styleClass="form-button" id="cbSalvarIgreja" value="Salvar" reRender="pgMensagens,igrejaTable,idfsDadosPessoais" action="#{igrejaCadastroBean.salvar}" >	</a4j:commandButton>
			</div >
		<div class="field-clear"></div>
		
		 <t:fieldset id="idfsDadosIgreaj" style="width: 600px; float: left" legend="Filtros">
		 	 <div class="grid-6-12">
					<h:outputLabel class="form-lbl"  value="Nome:"/>				
					<h:inputText styleClass="form-txt"  value="#{igrejaCadastroBean.igrejaPesquisa.nome}" id="nomePesquisa" />
				 </div>
				  <div class="grid-2-12">
					<h:outputLabel class="form-lbl"  value="Cód. Pesquisa:"/>				
					<h:inputText styleClass="form-txt"  value="#{igrejaCadastroBean.igrejaPesquisa.coSeqIgreja}" id="codPesquisa">
						<rich:jQuery selector="#codPesquisa" query="numeric()" timing="onload"/>
					</h:inputText>
				 </div>	
				   <div class="grid-3-12">
					<h:outputLabel class="form-lbl"  value="CNPJ"/>				
					<h:inputText styleClass="form-txt" style="width: 135px" value="#{igrejaCadastroBean.igrejaPesquisa.cnpj}" id="cnpjPesquisa" >
						 <rich:jQuery selector="#cnpjPesquisa" query="mask('99.999.999/9999-99')" timing="onload"/>
					</h:inputText>
				</div>	
			<div class="field-clear"></div>
			</t:fieldset>
		 <div class="grid-2-12">
					<a4j:commandButton id="cbPesquisar" process="idfsDadosIgreaj" ajaxSingle="true"  style="margin-top:37px" styleClass="form-button" action="#{igrejaCadastroBean.pesquisarIgreja}" reRender="igrejaTable" value="Pesquisar" >
					</a4j:commandButton>
				</div>
		 <div class="field-clear"></div>
		 <div style="padding: 0px" >
			 	<rich:dataTable  onRowMouseOver="this.style.backgroundColor='#F1F1F1'"
                    			onRowMouseOut="this.style.backgroundColor='#{a4jSkin.tableBackgroundColor}'" 
                    			width="750" border="0" align="center" id="igrejaTable"  var="igreja" value="#{igrejaCadastroBean.listaIgrejas}" >
				  <f:facet  name="header">
                    <rich:columnGroup >
                            <rich:column style="text-align: center;"  styleClass="ui-state-default" >
                                <strong><h:outputText value="Cód. Igreja" /></strong>
                            </rich:column>
                            <rich:column style="text-align: center;"  styleClass="ui-state-default" >
                                <strong><h:outputText value="Nome" /></strong>
                            </rich:column>
                            <rich:column style="text-align: center;"  styleClass="ui-state-default" >
                                <strong><h:outputText value="CNPJ" /></strong>
                            </rich:column>
                             <rich:column style="text-align: center;"  styleClass="ui-state-default" >
                                <strong><h:outputText value="Telefone" /></strong>
                            </rich:column>
                             <rich:column style="text-align: center;"  styleClass="ui-state-default" >
                                <strong><h:outputText value="Operações" /></strong>
                            </rich:column>
                    	</rich:columnGroup>
                  </f:facet>
 				<rich:columnGroup >	
 					<rich:column  style="text-align: center;" >
						<h:outputText value="#{igreja.coSeqIgreja}" />
					</rich:column>		
					 <rich:column style="text-align: center;" >
						<h:outputText value="#{igreja.nome}" />
					</rich:column>
					<rich:column  style="text-align: center;">
						<h:outputText value="#{igreja.cnpj}" />
					</rich:column>
					<rich:column style="text-align: center;" >
						<h:outputText value="#{igreja.telefone}" />
					</rich:column>
					<rich:column style="text-align: center;" >
						<a4j:commandLink id="removerIgreja" ajaxSingle="true" action="#{igrejaCadastroBean.excluir}" reRender="pgMensagens,igrejaTable"  >
							 <h:graphicImage value="/resources/imagens/ico_excluir.gif" id="gIExcluirIgreja" styleClass="hidelink"/>
							 <f:setPropertyActionListener target="#{igrejaCadastroBean.coIgreja}" value="#{igreja.coSeqIgreja}"/>  
						</a4j:commandLink>
						<a4j:commandLink id="editarIgreja" ajaxSingle="true" value=" " reRender="idfsDadosPessoais"  >
							<h:graphicImage value="/resources/imagens/ico_editar.gif" id="gIEdidarIgreja" styleClass="hidelink"/>
							 <f:setPropertyActionListener target="#{igrejaCadastroBean.igreja}" value="#{igreja}"/>  
						</a4j:commandLink>
					</rich:column>
				</rich:columnGroup>
			</rich:dataTable>
		</div>
		</h:form>
		</div>
		<t:saveState value="#{igrejaCadastroBean.igrejaPesquisa}"/>
		<t:saveState value="#{igrejaCadastroBean.igreja}"/>  
	</ui:define>
</ui:composition>

